package com.woniuxy.commons.factory;

import com.itextpdf.text.DocumentException;
import com.woniuxy.commons.dto.ExamDto;
import com.woniuxy.commons.dto.PaperDto;
import com.woniuxy.commons.entity.Exam;
import com.woniuxy.commons.entity.Paper;
import com.woniuxy.commons.entity.PaperStructure;
import com.woniuxy.commons.entity.ResponseEntity;
import com.woniuxy.commons.service.RemoteExamService;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.util.Arrays;

/**
 * @author 吴毛伟
 * @date:2020/7/28 11:09
 * @description:
 */
@Component
public class RemoteExamServiceFactory implements FallbackFactory<RemoteExamService> {
    @Override
    public RemoteExamService create(Throwable throwable) {
        return new RemoteExamService() {
            @Override
            public Exam findById(int id) {
                return null;
            }

            @Override
            public ResponseEntity<Paper> findPaperByPaperId(int paperId) {
                return (ResponseEntity<Paper>) Arrays.asList(new Paper().setName("请联系管理员！"));
            }

            @Override
            public ResponseEntity<PaperStructure> findPaperStructureByPaperId(int paperId) {
                return (ResponseEntity<PaperStructure>) Arrays.asList(new PaperStructure().setAnswerNum(11111111));
            }

            @Override
            public ResponseEntity<String> printPaper(int paperId) throws IOException, DocumentException {
                return (ResponseEntity<String>) Arrays.asList("出问题了，请联系管理员");
            }

            @Override
            public ResponseEntity<PaperDto> getFullPaper(int paperId) {
                return new ResponseEntity<PaperDto>().setMessage("出问题了！");
            }

            @Override
            public ResponseEntity conditionAndPageSearch(ExamDto examDto) {
                return null;
            }

            @Override
            public Exam findExamById(Exam exam) {
                return null;
            }
        };
    }
}
